package com.exchange.util;

import java.util.HashMap;
import java.util.Map;

import com.jfinal.kit.Kv;

/**
 * tradeview工具类
 *
 * @author zy
 * @version 1.0
 * @create 2019-05-11 10:03 PM
 **/
public class ChartUtils {

    /**
     * 默认
     */
    public static final String [] DEFAULT_SUP_RES = {"1","5","15","30","60","480","1D","1W"};


    /**
     * chart 配置
     * @return
     */
    public static Kv config(){
    	Kv data = Kv.create();
        // 服务器是否反馈样式信息
        data.set("supports_marks", false);
        // 是否获取服务器时间戳
        data.set("supports_time", true);
        // 是否获取服务器查询，支持搜索
        data.set("supports_search", true);

        data.set("supports_group_request", false);
        // 默认时间轴线
        data.set("supported_resolutions", DEFAULT_SUP_RES);
        return data;
    }

    /**
     * 无数据返回
     * @return
     */
    public static Map<String, Object> noData(){
        Map<String, Object> data = new HashMap<String, Object>();
        data.put("s", "no_data");
        return data;
    }

    /**
     * symbol对象
     * @return
     */
    public static Kv symbol() {
    	Kv vo = Kv.by("timezone", "Asia/Shanghai")//时区
    			  .set("session","24x7")//时效
    			  .set("has_intraday",true)//盘内数据
    			  .set("supported_resolutions",DEFAULT_SUP_RES)//盘内时间切换
    			  .set("type","stock")//类型
    			  .set("volume_precision",8)//深度位数
    			  .set("pointvalue",1)//
    			  .set("minmov",1)
    			  .set("minmov2",0)
    			  .set("has_no_volume",false)//是否包含深度
    			  .set("pricescale",100000000);//小数位数
        return vo;
    }

}
